package leetcode.dynamic;

import java.util.Arrays;

/**
 * @Description: https://leetcode.cn/problems/pile-box-lcci/description/
 * @Author Ammar
 * @Create 2023/9/13 14:26
 */
public class _面试题_08_13_堆箱子 {
    public int pileBox(int[][] box) {
        Arrays.sort(box, (a, b) -> {
            return a[0] - b[0];
        });

        int[] dp = new int[box.length];
        int res = 0;
        for (int i = 0; i < box.length; i++) {
            for (int j = 0; j < i; j++) {
                if (box[i][0] > box[j][0] && box[i][1] > box[i][1] && box[i][2] > box[i][2]) {
                    dp[i] = Math.max(dp[i], dp[j]);
                }
            }
            dp[i] += box[i][2];
            res = Math.max(dp[i], res);
        }
        return res;
    }
}
